package com.amor.workpcs.service.impl;

import com.amor.workpcs.entity.WorkHours;
import com.amor.workpcs.dao.WorkHoursDao;
import com.amor.workpcs.service.WorkHoursService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (WorkHours)表服务实现类
 *
 * @author makejava
 * @since 2021-09-14 11:01:50
 */
@Service("workHoursService")
public class WorkHoursServiceImpl implements WorkHoursService {
    @Resource
    private WorkHoursDao workHoursDao;

    /**
     * 通过ID查询单条数据
     *
     * @param workHoursId 主键
     * @return 实例对象
     */
    @Override
    public WorkHours queryById(Integer workHoursId) {
        return this.workHoursDao.queryById(workHoursId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<WorkHours> queryAllByLimit(int offset, int limit) {
        return this.workHoursDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param workHours 实例对象
     * @return 实例对象
     */
    @Override
    public WorkHours insert(WorkHours workHours) {
        this.workHoursDao.insert(workHours);
        return workHours;
    }

    /**
     * 修改数据
     *
     * @param workHours 实例对象
     * @return 实例对象
     */
    @Override
    public WorkHours update(WorkHours workHours) {
        this.workHoursDao.update(workHours);
        return this.queryById(workHours.getWorkHoursId());
    }

    /**
     * 通过主键删除数据
     *
     * @param workHoursId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer workHoursId) {
        return this.workHoursDao.deleteById(workHoursId) > 0;
    }
}